package com.rceeslca.modules.cam.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rceeslca.common.utils.Result;
import com.rceeslca.modules.cam.param.PageQueryParam;
import com.rceeslca.modules.cam.service.CamAttenService;
import com.rceeslca.modules.cam.vo.AttenCourseVo;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 考勤
 */
@Api(tags="考勤")
@AllArgsConstructor
@RestController
@RequestMapping("/cam/atten")
public class CamAttendanceController {

    @Autowired
    private CamAttenService camAttenService;


    /**
     * 分页查询课程考勤
     * @param param 条件参数
     */
    @PostMapping("pageCourse")
    public Result<IPage<AttenCourseVo>> pageCourse(@RequestBody PageQueryParam<AttenCourseVo> param) {

        Page<AttenCourseVo> page = new Page<>(param.getPageNum(),param.getPageSize());
        IPage<AttenCourseVo> iPage = camAttenService.pageCourse(page,param.getQuery());

        return new Result<IPage<AttenCourseVo>>().ok(iPage);
    }


    /**
     * 分页查询请假
     * @param param 条件参数
     */
    @PostMapping("pageLeave")
    public Result<IPage<AttenCourseVo>> pageLeave(@RequestBody PageQueryParam<AttenCourseVo> param) {

        Page<AttenCourseVo> page = new Page<>(param.getPageNum(),param.getPageSize());
        IPage<AttenCourseVo> iPage = camAttenService.pageLeave(page,param.getQuery());

        return new Result<IPage<AttenCourseVo>>().ok(iPage);
    }


    /**
     * 分页查询课程详情
     * @param param 条件参数
     */
    @PostMapping("pageCourseItem")
    public Result<IPage<AttenCourseVo>> pageCourseItem(@RequestBody PageQueryParam<AttenCourseVo> param) {

        Page<AttenCourseVo> page = new Page<>(param.getPageNum(),param.getPageSize());
        IPage<AttenCourseVo> iPage = camAttenService.pageCourseItem(page,param.getQuery());

        return new Result<IPage<AttenCourseVo>>().ok(iPage);
    }

}
